// import axios from '@/utils/request'
const TYPE = {
  operation: '手动',
  purchase: '采购入库',
  sales: '销售出库'
}
export default {
  StoreInbound: {
    entity: { name: 'Inbound', prefix: () => `store/${localStorage.getItem('storeId')}` },
    list: {
      export: {
        query: {
          '@display': `{
            'stock' : 'entity.getStock().getSpecification().getName()',
            'quantity' : 'entity.getQuantity()',
            'unitPrice' : 'entity.getUnitPrice()',
            'comment' : 'entity.getComment()',
            'cretedTime' : 'entity.getCreatedTime().format("Y-m-d H:i:s")'
          }`,
          limit: 10000000
        },
        label: {
          'stock': '产品',
          'quantity': '数量',
          'unitPrice': '单价',
          'comment': '原因',
          'cretedTime': '时间'
        }
      },
      query: {
        '@expands': `['entity.stock']`,
        '@order': `entity.createdTime|DESC`
      },
      disabled_actions: ['edit', 'delete', 'lines'],
      list_filter: {
        'stock.specification.product.name': '产品',
        startTime: {
          expression: `
          entity.getCreatedTime() >= datetime.get(":value")
        `,
          label: '开始时间',
          type: 'datetime'
        },
        endTime: {
          expression: `
          entity.getCreatedTime() < datetime.get(":value")
        `,
          label: '结束时间',
          type: 'datetime'
        }
      },
      list_display: [
        {
          property: 'stock.__metadata.specification.__toString',
          label: '产品'
        },
        'quantity',
        {
          property: 'type',
          label: '类型',
          component: {
            props: ['data'],
            render(h) {
              return <div>
                { TYPE[this.data] }
              </div>
            }
          }
        },
        {
          property: 'comment',
          label: '原因'
        },
        'createdTime'
      ]
    },
    form: {
      fields: [
        {
          property: 'stock',
          field_options: {
            label: '产品'
          }
        },
        'quantity',
        {
          property: 'unitPrice',
          field_options: {
            label: '单价'
          }
        },
        {
          property: 'comment',
          field_options: {
            label: '原因'
          }
        }
      ]
    }
  }
}

